import random
import ecdsa#ecdsa 函数库
import hashlib
def fake_sig():
    ECDSA_gen=ecdsa.NIST256p.generator
    #生成椭圆曲线和基点ECDSA_gen
    sk= random.randrange(1,ECDSA_gen.order()-1)
    #选择私有密钥sk
    pk = ecdsa.ecdsa.Public_key(ECDSA_gen,ECDSA_gen * sk)
    #利用基点计算公钥pk
    _sk = ecdsa.ecdsa.Private_key(pk,sk)
    info= "I'm feng ying lun"
    m = int(hashlib.sha1(info.encode("utf8")).hexdigest(),16)
    #用sha1对info,x,y进行哈希
    Sk = random.randrange(1,ECDSA_gen.order()-1)
    sig = _sk.sign(m,Sk)
    #计算s≡r - m * sk (mod n)并签名
    return(sig.r,sig.s)

temp=()
temp=fake_sig()
print("伪造后的签名为：")
print(temp)

